home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 3 / CD ACTUAL 3.iso / linux / incoming / libgr-2.000 / libgr-2 / libgr-2.0.3 / rle / cmd_name.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-14  |  1.4 KB  |  54 lines

  1. /*
  2.  * This software is copyrighted as noted below.  It may be freely copied,
  3.  * modified, and redistributed, provided that the copyright notice is 
  4.  * preserved on all copies.
  5.  * 
  6.  * There is no warranty or other guarantee of fitness for this software,
  7.  * it is provided solely "as is".  Bug reports or fixes may be sent
  8.  * to the author, who may or may not act on them as he desires.
  9.  *
  10.  * You may not include this software in a program or other software product
  11.  * without supplying the source, or without informing the end-user that the 
  12.  * source is available for no extra charge.
  13.  *
  14.  * If you modify this software, you should include a notice giving the
  15.  * name of the person performing the modification, the date of modification,
  16.  * and the reason for such modification.
  17.  */
  18. /* 
  19.  * cmd_name.c - Extract command name from argv[0].
  20.  * 
  21.  * Author:    Spencer W. Thomas
  22.  *         EECS Dept.
  23.  *         University of Michigan
  24.  * Date:    Wed Jun 27 1990
  25.  * Copyright (c) 1990, University of Michigan
  26.  */
  27.  
  28. static char no_name[] = "(no-name)";
  29.  
  30. char *
  31. cmd_name( argv )
  32. char **argv;
  33. {
  34.     register char *cp, *a;
  35.  
  36.     /* Be paranoid. */
  37.     if ( !argv || !(a = *argv) )
  38.     return no_name;
  39.  
  40.     /* Find end of file name. */
  41.     for ( cp = a; *cp; cp++ )
  42.     ;
  43.  
  44.     /* Find last / or beginning of command name. */
  45.     for ( cp--; *cp != '/' && cp > a; cp-- )
  46.     ;
  47.     
  48.     /* If it's a /, skip it. */
  49.     if ( *cp == '/' )
  50.     cp++;
  51.  
  52.     return cp;
  53. }
  54.